/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Outputsdemo;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

/**
 *
 * @author Administrator
 */
public class Notices {

    private String getTodayName() {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    private static class notices {

        public notices() {
        }
    }
    private File file;

    private static class FileOutputStrea extends FileOutputStream {

        
        public FileOutputStrea(File file, boolean b) {
         
        }
    }

    private static class Notces extends Notices {

        public Notces() {
        }
    }
    private String dateString;
    public String gerTodayName(){
        Date date =new Date();
        SimpleDateFormat formatter=new SimpleDateFormat("yyyy-mm-dd");
        String dateSting=formatter.format(date);
        return dateString;
        
    }
    public String getTomorrowName(){
        Date date=new Date();
        Calendar calendar=new GregorianCalendar();
        calendar.setTime(date);
        calendar.add(calendar.DATE,1);
        date=calendar.getTime();
        SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd");
        String dateString=fotmatter.format(date);
        return dateString;
        
    }
    public void getTodayNotices()throws FileNotFoundException,IOException{
        File file=new File ("notices/"+getTodayName()+".txt");
        if(file.exists()){
            FileReader f=new FileReader(file);
            BufferedReader br=new BufferedReader(f);
            String temp=null;
            while ((temp=br.readLine())!=null){
                System.out.println(temp);
            }
        }else{
            System.out.println("今天没什么特别要提醒的。");
        }
        
        
    }
 public boolean setTomorrowNotices(String notice) throws IOException {
       
        File file=new File ("notices");
        if(!file.exists()){
            file.mkdir();
           
        }
        file=new File("notices/"+getTomorrowName()+".txt");
        if(!file.exists()){
            file.createNewFile();        
      
            }
        }
           
            FileOutputStream f=new FileOutputStrea(file,true);
            PrintWriter p=new PrintWriter(f,true);
            p.println(notices);
            System.out.println("成功添加一条明天的备忘信息");
            return true;
        }
        public static void main(String[] args) throws IOException{
            Notices n=new Notces();
            String dateString =n.gerTodayName();
            System.out.println(dateString);
            String tomorrowString =n.getTomorrowName();
            System.out.println(tomorrowString);
            n.setTomorrowNotices("明天要去逛街！取钱去！");
        

}
           

   
    



